﻿<?php
namespace Member\Controller;
use Think\Page;
use Think\Controller;
use Member\Controller\MemberController;

class PintuanController extends MemberController{
	/**
	 * 2015-11-24
	 * 订单列表
	 */
	public function index(){
		$order=D('FightgroupOrder','Logic');
		$product=D('FightgroupProduct','Logic');
		$where=array(
				'uid'=>UID,
				'ishidden'=>0,
				'ispay'=>1, 
		);
		//搜索条件
		if(IS_POST){
			$keyword = I('post.Keyword');//订单号、昵称
			if(isset($keyword)){
				$where['ordernumber|nickname'] = array('like','%'.$keyword.'%');
				session('keyword',$keyword);
				$this->assign('keyword',$keyword);
			}
				
			//时间段(创建时间)
			$time = I('post.Time');
			if(!empty($time)){
				$arr = explode(' - ',I('post.Time'));
				$time0 = strtotime($arr[0]);
				$time1 = strtotime($arr[1]);
				$where['createtime'] = array('between',array($time0,$time1));
				$this->assign('time',$time);
				session('time',$time);
			}
		
		}
		
		$count=$order->where($where)->count();
		$page=new Page($count,15);
		$show=$page->show();
		
		$orderarr=$order->where($where)->order('createtime desc')->limit($page->firstRow,$page->listRows)->select();
		foreach($orderarr as $key=>$value){//通过商品id查出商品名
			$productarr=$product->where(array('id'=>$value['productid']))->find();
			$orderarr[$key]['productname']=$productarr['name'];
		}
		$this->assign('orderarr',$orderarr);
		$this->assign('page',$show);
		$this->display();
	}
	/**
	 * 订单列表删除
	 */
	public function delete_order(){
		$order=D('FightgroupOrder','Logic');
		$id=I('get.id',0);
		$res=$order->where(array('id'=>$id))->save(array('ishidden'=>1));
		if($res){
			redirect(U('index'));
		}else{
			$this->error('删除失败');
		}
		
	} 
	
	/**
	 * 订单详细信息
	 */
	public function index_detail(){
		$order=D('FightgroupOrder','Logic');
		$product=D('FightgroupProduct','Logic');
		$address=D('FightgroupAddress','Logic');
		
		$id=I('get.id',0);
		
		$orderarr=$order->where(array('id'=>$id))->find();
		//查出相应商品id的商品名
		$productarr=$product->where(array('id'=>$orderarr['productid']))->find();
		$orderarr['name']=$productarr['name'];
		
		//根据地址id查出该人的信息
		$addressarr=$address->where(array('id'=>$orderarr['addressid']))->find();
		$orderarr['address']=$addressarr['address'];//地址
		$orderarr['linkman']=$addressarr['linkman'];//联系人
		$orderarr['linktel']=$addressarr['linktel'];//联系电话
		
		$this->assign('order',$orderarr);
		$this->display();
	}
	
	
	/**
	 * 产品列表
	 */
	public function list_product(){
		$product=D('FightgroupProduct','Logic');
		
		$where=array(
				'uid'=>UID,
				'ishidden'=>0,
		);
		
		//搜索条件
		if(IS_POST){
			$keyword = I('post.Keyword');//商品名
			if(isset($keyword)){
				$where['name'] = array('like','%'.$keyword.'%');
				session('keyword',$keyword);
				$this->assign('keyword',$keyword);
			}
			
			//时间段(创建时间)
			$time = I('post.Time');
			if(!empty($time)){
				$arr = explode(' - ',I('post.Time'));
				$time0 = strtotime($arr[0]);
				$time1 = strtotime($arr[1]);
				$where['createtime'] = array('between',array($time0,$time1));
				$this->assign('time',$time);
				session('time',$time);
			}
				
		}
// 		dump($where);
		$count=$product->where($where)->count();
		$page=new Page($count,15);
		$show=$page->show();
		
		$productlist=$product->where($where)->order('ispublish desc,createtime desc')->limit($page->firstRow,$page->listRows)->select();
		$this->assign('productlist',$productlist);
		
		$this->assign('page',$show);
		$this->display();
	}
	
	/**
	 * 产品添加显示与操作
	 */
	public function add_product(){
		$product=D('FightgroupProduct','Logic');
		$productgroup=D('FightgroupProductgroup','Logic');
		$productspec=D('FightgroupProductspec','Logic');
		
		if(IS_POST){
			$time=time();
			$name=I('post.name');
			$id=I('post.id');
			
			$chengtuan=I('post.chengtuan');//各成团人数
			$chengtuanprice=I('post.chengtuanprice');//各成团价格
			
			//查出各成团最低价
			$min = $chengtuanprice[0];
			
			for($i = 1; $i < count($chengtuanprice); $i++){
				
				if($min > $chengtuanprice[$i]){
					$min = $chengtuanprice[$i];
				}
			}
			$guige=I('post.guige');
			$total=I('post.total');
			$rest=I('post.rest');
			
			
			//没有id则添加数据，否则修改相应的id的数据信息
			if(empty($id)){
				$where=array(
						'uid'=>UID,
						'name'=>$name,
						'coverimg'=>I('post.ImgPath'),
						'imgpath'=>serializeMysql(I('post.PicPath')),
						'oriprice'=>I('post.oriprice'),
						'lowestprice'=>$min,
						'description'=>I('post.description'),
						'remark'=>I('post.remark'),
						'spec'=>I('post.spec'),
						'createtime'=>$time,
						'buynumber'=>0,
						'ishidden'=>0,  //0为显示  1不显示
						'ispublish'=>0,  //0未发布  1已发布
				);
				$res=$product->add($where);
			}else{
				$where=array(
						'uid'=>UID,
						'name'=>$name,
						'coverimg'=>I('post.ImgPath'),
						'imgpath'=>serializeMysql(I('post.PicPath')),
						'oriprice'=>I('post.oriprice'),
						'lowestprice'=>$min,
						'description'=>I('post.description'),
						'remark'=>I('post.remark'),
						'spec'=>I('post.spec'),
						'createtime'=>$time,
						'buynumber'=>0,
						'ishidden'=>0,  //0为显示  1不显示
						'ispublish'=>I('post.ispublic'),  //0未发布  1已发布
				);
				$res=$product->where(array('id'=>$id))->save($where);
				
			}
			
			//判断操作是否成功
			if($res){
				$map=array();
				$wm=array();
				$productarr=$product->where(array('name'=>$name,'createtime'=>$time))->find();
				
				
				//删除相应的id的团、规格
				if(!empty($id)){
					$productgroup->where(array('productid'=>$id))->delete();
					$productspec->where(array('productid'=>$id))->delete();
				}
				
					
				
				
				//再次将团、规格分配好后，一一添加
				for($i=0;$i<count($chengtuan);$i++){
					$map=array(
							'uid'=>UID,
							'productid'=>$productarr['id'],
							'groupnumber'=>$chengtuan[$i],
							'price'=>$chengtuanprice[$i]
					);
					
					$productgroup->add($map);
				}
				
				for($i=0;$i<count($guige);$i++){
					if(empty($id)){
						$wm=array(
								'uid'=>UID,
								'productid'=>$productarr['id'],
								'spectype'=>$guige[$i],
								'totalnumber'=>$total[$i],
								'restnumber'=>$total[$i],
						);
					}else{
						$wm=array(
								'uid'=>UID,
								'productid'=>$productarr['id'],
								'spectype'=>$guige[$i],
								'totalnumber'=>$total[$i],
								'restnumber'=>$rest[$i],
						);
					}
					
					
					$productspec->add($wm);
				}
				
				$this->ajaxReturn(array('ret'=>1));
			}else{
				$this->ajaxReturn(array('ret'=>2,'id'=>$id));
			}
			exit;
		}
		
		if(IS_GET){
			$id=I('get.id',0);
			//查看对应id的商品信息
			$productinfo=$product->where(array('id'=>$id))->find();
			//轮播图进行反序列化
			$productinfo['imgpath']=serializeMysql($productinfo['imgpath'],1);
// 			dump($productinfo['imgpath']);

			//查找相应的商品组
			$productgrouparr=$productgroup->where(array('productid'=>$id))->select();
			
			//查找相应的规格组
			$productspecarr=$productspec->where(array('productid'=>$id))->select();
// 			dump($productgrouparr);
			$this->assign('productgrouparr',$productgrouparr);
			$this->assign('productspecarr',$productspecarr);
			$this->assign('productinfo',$productinfo);
			$this->assign('id',$id);
		}
		$this->display();
	}
	
	/**
	 * 商品删除
	 */
	
	public function delete_product(){
		$product=D('FightgroupProduct','Logic');
		$id=I('get.id',0);
		$res=$product->where(array('id'=>$id))->save(array('ishidden'=>1));
		if($res){
			redirect(U('list_product'));
		}else{
			$this->error('删除失败',U('list_product'));
		}
	}
	/**
	 * 商品发布
	 */
	public function publish_product(){
		$product=D('FightgroupProduct','Logic');
		$id=I('get.id',0);
		$res=$product->where(array('id'=>$id))->save(array('ispublish'=>1));
		if($res){
			redirect(U('list_product'));
		}else{
			$this->error('发布失败',U('list_product'));
		}
	}
	/**
	 * 取消商品发布
	 */
	public function npublish_product(){
		$product=D('FightgroupProduct','Logic');
		$id=I('get.id',0);
		$res=$product->where(array('id'=>$id))->save(array('ispublish'=>0));
		if($res){
			redirect(U('list_product'));
		}else{
			$this->error('发布取消失败',U('list_product'));
		}
	}
	
	/**
	 * 拼团流程
	 */
	public function liucheng(){
		$process=D('FightgroupProcess','Logic');
		$where=array(
				'uid'=>UID,
		);
		$processarr=$process->where($where)->find();
		$this->assign('processarr',$processarr);
		$this->display();
	}
	
	/**
	 * 拼团流程添加、修改
	 */
	public function add_update(){
		$process=D('FightgroupProcess','Logic');
		$id=I('post.id');
		$where=array(
				'uid'=>UID,
				'ispost'=>I('post.ispost'),
				'expiredtime'=>I('post.expiredtime'),
				'description'=>I('post.description'),
		);
		//id为空，进行添加操作。否则进行修改操作
		if(empty($id)){
			$res=$process->add($where);
			if($res){
				$this->ajaxReturn(array('ret'=>1,'msg'=>'添加成功'));
			}else{
				$this->ajaxReturn(array('ret'=>2,'msg'=>'添加失败'));
			}
		}else{
			$res=$process->where(array('id'=>$id))->save($where);
			if($res){
				$this->ajaxReturn(array('ret'=>1,'msg'=>'修改成功'));
			}else{
				$this->ajaxReturn(array('ret'=>2,'msg'=>'修改失败'));
			}
		}
	}
	
	/**
	 * 成团列表
	 */
	public function list_tuan(){
		$group=D('FightgroupGroup','Logic');
// 		$order=D('FightgroupOrder','Logic');
		$product=D('FightgroupProduct','Logic');
		$grouplog=D('FightgroupGrouplog','Logic');
		
		$where=array(
				'uid'=>UID,
				'ishidden'=>0,
		);
		$where['status']=array('neq',7);
		//查找条件
		if(IS_POST){
			$keyword = I('post.Keyword');//团类型（人数）
			if(isset($keyword)){
				$where['groupnumber'] = array('eq',$keyword);
				session('keyword',$keyword);
				$this->assign('keyword',$keyword);
			}
				
			//时间段(创建时间)
			$time = I('post.Time');
			if(!empty($time)){
				$arr = explode(' - ',I('post.Time'));
				$time0 = strtotime($arr[0]);
				$time1 = strtotime($arr[1]);
				$where['createtime'] = array('between',array($time0,$time1));
				$this->assign('time',$time);
				session('time',$time);
			}
		
		}
		
		$count=$group->where($where)->count();
		$page=new Page($count,15);
		$show=$page->show();
		
		$grouparr=$group->where($where)->order('createtime desc')->limit($page->firstRow,$page->listRows)->select();
		foreach($grouparr as $key=>$value){
			//查找开团的人
			$grouplogarr=$grouplog->where(array('groupid'=>$value['id'],'isleader'=>1))->find();
			//查找商品名
			$productarr=$product->where(array('id'=>$value['productid']))->find();
			$grouparr[$key]['buyername']=$grouplogarr['nickname'];//购买人昵称
			$grouparr[$key]['productname']=$productarr['name'];//商品名称
		}
		
		$this->assign('page',$show);
		$this->assign('grouparr',$grouparr);
		$this->display();
	}
	
	/**
	 * 团的详细信息
	 */
	public function detail_tuan(){
		$group=D('FightgroupGroup','Logic');
		$product=D('FightgroupProduct','Logic');
		$grouplog=D('FightgroupGrouplog','Logic');
		$address=D('FightgroupAddress','Logic');
		$order=D('FightgroupOrder','Logic');
		
		$id=I('get.id',0);//团id
		$grouparr=$group->where(array('id'=>$id))->find();
		//查找商品名
		$productarr=$product->where(array('id'=>$grouparr['productid']))->find();
		$grouparr['productname']=$productarr['name'];
		//将创建团的时间戳转化为相应的年月日
		$grouparr['createtime']=date('Y-m-d H:i:s',$grouparr['createtime']);
		if($grouparr['period'] != 0){
			$grouparr['period']=date('Y-m-d H:i:s',$grouparr['period']);
		}
		
		//查找团成员
		$grouplogarr=$grouplog->where(array('groupid'=>$id,'ishidden'=>0))->select();
		foreach($grouplogarr as $key=>$value){
			//查找相应团员所下订单的id
			$orderarr=$order->where(array('ordernumber'=>$value['ordernumber']))->find();
			$addressarr=$address->where(array('id'=>$orderarr['addressid']))->find();
			
			$grouplogarr[$key]['linkman']=$addressarr['linkman'];//联系人
			$grouplogarr[$key]['address']=$addressarr['address'];//地址
			$grouplogarr[$key]['linktel']=$addressarr['linktel'];//联系方式
			$grouplogarr[$key]['orderid']=$orderarr['id'];//订单id
		}
// 		dump($grouplogarr[0]['orderid']);
		$this->assign('grouplogarr',$grouplogarr);
		$this->assign('grouparr',$grouparr);
		$this->display();
	}
	
	/**
	 * 删除该团
	 */
	public function delete_tuan(){
		$group=D('FightgroupGroup','Logic');
		$id=I('get.id',0);
		$res=$group->where(array('id'=>$id))->save(array('ishidden'=>1));
		if($res){
			redirect(U('Pintuan/list_tuan'));
		}else{
			$this->error('删除失败');
		}
	}
	
	/**
	 * 退款申请列表
	 */
	public function list_tui(){
		$refund=D('FightgroupRefund','Logic');
		$where=array(
				'uid'=>UID,
				'ishidden'=>0,
		);
		
		if(IS_POST){
			$keyword = I('post.Keyword');//昵称
			if(isset($keyword)){
				$where['nickname|productname|ordernumber'] = array('like','%'.$keyword.'%');
				session('keyword',$keyword);
				$this->assign('keyword',$keyword);
			}
		
			//时间段(创建时间)
			$time = I('post.Time');
			if(!empty($time)){
				$arr = explode(' - ',I('post.Time'));
				$time0 = strtotime($arr[0]);
				$time1 = strtotime($arr[1]);
				$where['createtime'] = array('between',array($time0,$time1));
				$this->assign('time',$time);
				session('time',$time);
			}
		
		}
		
		$count=$refund->where($where)->count();
		$page=new Page($count,15);
		$show=$page->show();
		
		//status(审核状态)，按审核状态进行排序
		$refundarr=$refund->where($where)->order('status asc, createtime desc')->limit($page->firstRow,$page->listRows)->select();
		
		$this->assign('page',$show);
		$this->assign('refundarr',$refundarr);
		$this->display();
	}
	
	/**
	 * 退款申请详细信息
	 */
	public function detail_tui(){
		$refund=D('FightgroupRefund','Logic');
		$id=I('get.id',0);
		$refundarr=$refund->where(array('id'=>$id))->find();
		$refundarr['createtime']=date('Y-m-d H:i:s',$refundarr['createtime']);//申请提交时间
		$refundarr['successtime']=date('Y-m-d H:i:s',$refundarr['successtime']);//申请通过时间
		$this->assign('refundarr',$refundarr);
		
		$this->display();
	}
	
	/**
	 * 删除退款申请
	 */
	public function delete_tui(){
		$refund=D('FightgroupRefund','Logic');
		$id=I('get.id',0);
		$res=$refund->where(array('id'=>$id))->save(array('ishidden'=>1));
		if($res){
			redirect(U('Pintuan/list_tui'));
		}else{
			$this->error('删除失败');
		}
	}
	
	/**
	 * 同意退款申请
	 */
	public function remind_tui(){
		$refund=D('FightgroupRefund','Logic');
		$order=D('FightgroupOrder','Logic');
		$grouplog=D('FightgroupGrouplog','Logic');
		$group=D('FightgroupGroup','Logic');
		$product=D('FightgroupProduct','Logic');
		
		$id=I('get.id',0);
		$res=$refund->where(array('id'=>$id))->save(array('status'=>1,'successtime'=>time()));
		if($res){
			$refundarr=$refund->where(array('id'=>$id))->find();
			//判断团是否过期
			$grouparr=$group->where(array('id'=>$refundarr['groupid']))->find();
			if($grouparr['isexpired']==0){//团未过期
				if($grouparr['status']!=5){//团状态不为取消
						$grouplogarr=$grouplog->where(array('groupid'=>$refundarr['groupid'],'openid'=>$refundarr['openid']))->find();
						//判断是团长、团员
						if($grouplogarr['isleader']==1){//团长
							//更改订单状态(退款成功)
							$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
							$map=array(
									'groupid'=>$refundarr['groupid'],
							);
							$map['ordernumber']=array('neq',$refundarr['ordernumber']);
							$order->where($map)->save(array('status'=>5));
							//更改团状态(团取消)
							$group->where(array('id'=>$refundarr['groupid']))->save(array('status'=>5));
							$productarr=$product->where(array('id'=>$group['productid']))->find();
							$successnumber=$productarr['buynumber']-1;
							$product->where(array('id'=>$group['productid']))->save(array('buynumber'=>$successnumber));
						}else{//团员
							//更改订单状态(退款成功)
							$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
							//删除退款成员
							$grouplog->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('ishidden'=>1));
							//查找团现有人数
							$grouparr=$group->where(array('id'=>$refundarr['groupid']))->find();
							$map=array(
									'hasjoin'=>$grouparr['hasjoin']-1,
									'status'=>1,
							);
							//更改团参加人数
							$group->where(array('id'=>$refundarr['groupid']))->save($map);
						}
				}else{
					$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
				}
				
			}else{//团已过期
				//谁提出申请就给谁退款
				$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
			}
			
			
			
			redirect(U('Pintuan/list_tui'));
		}else{
			$this->error('审核更改失败');
		}
	}
	
	/**
	 * 退款申请不通过
	 */
	public function remind_ntui(){
		$refund=D('FightgroupRefund','Logic');
		$order=D('FightgroupOrder','Logic');
		$id=I('get.id',0);
		$res=$refund->where(array('id'=>$id))->save(array('status'=>2));
		if($res){
			$refundarr=$refund->where(array('id'=>$id))->find();
			$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>2));
			redirect(U('Pintuan/list_tui'));
		}else{
			$this->error('操作出现问题');
		}
	}
	
	/**
	 * 退款申请操作
	 */
	public function action_tui(){
		$refund=D('FightgroupRefund','Logic');
		$order=D('FightgroupOrder','Logic');
		$grouplog=D('FightgroupGrouplog','Logic');
		$group=D('FightgroupGroup','Logic');
		
		$id=I('post.id');
		$status=I('post.status');
// 		$this->ajaxReturn(array('ret'=>$id));
		$res='';
		if($status==1){//申请审核通过
			$res=$refund->where(array('id'=>$id))->save(array('status'=>$status,'successtime'=>time()));
			if($res){
				$refundarr=$refund->where(array('id'=>$id))->find();
				//判断团是否过期
				$grouparr=$group->where(array('id'=>$refundarr['groupid']))->find();
				if($grouparr['isexpired']==0){//未过期
					if($grouparr['status']!=5){//团状态不为取消
						$grouplogarr=$grouplog->where(array('groupid'=>$refundarr['groupid'],'openid'=>$refundarr['openid']))->find();
						//判断是团长、团员
						if($grouplogarr['isleader']==1){//团长
							//更改订单状态(退款成功)
							$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
							$map=array(
									'groupid'=>$refundarr['groupid'],
							);
							$map['ordernumber']=array('neq',$refundarr['ordernumber']);
							$order->where($map)->save(array('status'=>5));
							//更改团状态(团取消)
							$group->where(array('id'=>$refundarr['groupid']))->save(array('status'=>5));
			
						}else{//团员
							//更改订单状态(退款成功)
							$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
							//删除退款成员
							$grouplog->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('ishidden'=>1));
							//查找团现有人数
							$grouparr=$group->where(array('id'=>$refundarr['groupid']))->find();
							$map=array(
									'hasjoin'=>$grouparr['hasjoin']-1,
									'status'=>1,
							);
							//更改团参加人数
							$group->where(array('id'=>$refundarr['groupid']))->save($map);
						}
					}else{
						//团取消后，团成员谁申请就给谁退款
						$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
					}
				}else{//已过期
					//谁提出申请就给谁退款
					$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>7));
				}
				$this->ajaxReturn(array('ret'=>1));
			}else{
				$this->ajaxReturn(array('ret'=>2));
			}
		}else if($status==2){//审核不通过
			$res=$refund->where(array('id'=>$id))->save(array('status'=>$status));
			if($res){
				$refundarr=$refund->where(array('id'=>$id))->find();
				$order->where(array('ordernumber'=>$refundarr['ordernumber']))->save(array('status'=>2));
				$this->ajaxReturn(array('ret'=>1));
			}else{
				$this->ajaxReturn(array('ret'=>2));
			}
		}else{
			$this->ajaxReturn(array('ret'=>2));
		}

	}
	
	
	/**
	 * 发货
	 */
	public function send(){
		$group=D('FightgroupGroup','Logic');
		$grouplog=D('FightgroupGrouplog','Logic');
		$refund=D('FightgroupRefund','Logic');
		$order=D('FightgroupOrder','Logic');
		
		$id=I('post.id');
		$grouparr=$group->where(array('id'=>$id))->find();
		
		//判断参团人数是否达到成团人数,没达到则返回并提示。反之进行下一步
		if($grouparr['hasjoin']!=$grouparr['groupnumber']&&$grouparr['hasjoin']<$grouparr['groupnumber']){
			$this->ajaxReturn(array('ret'=>2,'msg'=>'对不起，参团人数未达到成团人数，暂不能发货！'));
		}else{
			//判断成团后，是否有人提交退款申请
			$grouplogarr=$grouplog->where(array('groupid'=>$id,'ishidden'=>0,'status'=>0))->select();
			$num=0;
			foreach($grouplogarr as $key=>$value){
				$count=$refund->where(array('groupid'=>$id,'openid'=>$value['openid']))->count();
				$num=$num+$count;
			}
			//团中有人提交申请，则不予以发货并返回相应的提示
			if($num>0){
				$this->ajaxReturn(array('ret'=>2,'msg'=>'团中有人提交了退款申请，暂不能发货！'));
			}else{
				//查找参团人员(不包括已退款的)
				$grouplist=$grouplog->where(array('groupid'=>$id,'ishidden'=>0))->select();
// 				$this->ajaxReturn(array('ret'=>1,'msg'=>$grouplist));
				foreach($grouplist as $key=>$value){
					//发货，并修改订单下单状态（3->发货）
					$res=$order->where(array('ordernumber'=>$value['ordernumber']))->save(array('status'=>3));
				}
// 				$this->ajaxReturn(array('ret'=>1,'msg'=>$res));
				//修改团状态
				$group->where(array('id'=>$id))->save(array('status'=>3));
				$this->ajaxReturn(array('ret'=>1));
			}
		}
	}

}













